package com.hsgene.order.constants.v1;

/**
 * @Description: 套餐变更操作类型
 * @ProjectName: hdas-geneshop
 * @Package: com.hsgene.order.constants.v1
 * @Author: 江承良
 * @CreateDate: 2019/1/17 14:31
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */
public enum ActionType {
    NO_AMOUNT(0, "无差价"),
    REFUND_AMOUNT(1, "退差价"),
    SUPPLEMENT_AMOUNT(2, "补差价"),
    SUPPLEMENT_SAMPLE(3, "补样本无差价"),
    SUPPLEMENT_SAMPLE_REFUND(4, "补样本退差价"),
    SUPPLEMENT_SAMPLE_AMOUNT(5, "补样本补差价");

    private Integer code;

    private String actionType;

    ActionType(Integer code, String actionType) {
        this.code = code;
        this.actionType = actionType;
    }

    public static String desc(Integer code) {
        for (ActionType actionType : values()) {
            if (actionType.code.equals(code)) {
                return actionType.actionType;
            }
        }
        return null;
    }

    public static ActionType getEnum(int code) {
        for (ActionType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalStateException("非法的ActionType枚举code值：" + code);
    }

    /**
     * 是否需要补寄样本
     *
     * @return true：需要补寄样本
     */
    public boolean needSupplementSample() {
        return this.equals(SUPPLEMENT_SAMPLE) || this.equals(SUPPLEMENT_SAMPLE_REFUND) || this.equals(SUPPLEMENT_SAMPLE_AMOUNT);
    }

    /**
     * 是否需要补款
     *
     * @return true：需要补款
     */
    public boolean needSupplementAmount() {
        return this.equals(SUPPLEMENT_AMOUNT) || this.equals(SUPPLEMENT_SAMPLE_AMOUNT);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
